package com.ruoyi.project.system.domain.dto;

import com.ruoyi.common.utils.StringUtils;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.List;

@Data
@Accessors(chain = true)
public class AddressBook {

    private Integer queryId;

    private String displayName;

    private List<Phone> phones;

    private String phones_;

    public static String getTelName(List<AddressBook> addressBookList, String tel) {
        if (addressBookList == null || addressBookList.isEmpty() || StringUtils.isEmpty(tel)) {
            return "";
        }
        for (AddressBook addressBook : addressBookList) {
            for (Phone phone : addressBook.getPhones()) {
                if (tel.equals(phone.getValue())) {
                    return addressBook.getDisplayName();
                }
            }
        }
        return "";
    }

    public AddressBook() {
    }

    public AddressBook(Integer queryId) {
        this.queryId = queryId;
    }
}
